package thread;

public class Demo8 {

    public static Boolean  flag = true;
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            while (flag) {
                System.out.println("hello thread");
            }
        });
        System.out.println("thread线程启动");
        thread.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        flag = false;
        System.out.println("thread线程中断");
    }
}
